﻿using System;
using Presentation;
using Infrastructure;

namespace View
{
    public partial class WebView : System.Web.UI.Page, IView
    {
        private Presenter presenter;
        public event Action OnFindClick;
        public event Action OnOpenLogClick;

        public string requiredElement
        {
            get
            {
                return (string)Session["requiredElement"];
            }
            set
            {
                Session["requiredElement"] = value;
            }
        }

        public string mas
        {
            get
            {
                return (string)Session["mas"];
            }
            set
            {
                Session["mas"] = value;
            }
        }

        public string sortedMas
        {
            get
            {
                return (string)Session["sortedMas"];
            }
            set
            {
                Session["sortedMas"] = value;
            }
        }
        public string pos
        {
            get
            {
                return (string)Session["pos"];
            }
            set
            {
                Session["pos"] = value;
            }
        }
        public string error
        {
            get
            {
                return (string)Session["error"];
            }
            set
            {
                Session["error"] = value;
            }
        }
        public string logging
        {
            get
            {
                return (string)Session["error"];
            }
            set
            {
                Session["error"] = value;
            }
        }


        protected void Page_Load(object sender, EventArgs e)
        {

            if (Session["presenter"] == null)
            {
                presenter = new Presenter(this, new LoggerTxtFile("log_txt.txt"));
                Session["presenter"] = presenter;
            }
            else
            {
                presenter = (Presenter)Session["presenter"];
                presenter.SetView(this);
            }
        }

        protected void SearchDichotomy_Click(object sender, EventArgs e)
        {
            
            mas = InputMas.Text;
            requiredElement = InputElement.Text;
            OnFindClick();
            SortedMas.Text = sortedMas;
            ElementPosition.Text = pos;
            Errors.Text = error;

        }

        protected void showLOG_Click(object sender, EventArgs e)
        {

        }

    }
}